package com.innovation.chengzhangriji.ui.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;

import com.innovation.chengzhangriji.R;

public class CuteExtraTitleToolbar extends CuteToolbar {

    private static final int CUTE_BLUE = 0xFF19C9DB;

    private CuteTextView mTextExtraTitle;

    public CuteExtraTitleToolbar(Context context) {
        super(context);
        init(context);
    }

    public CuteExtraTitleToolbar(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public CuteExtraTitleToolbar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    public void setTextExtraTitleText(String text) {
        mTextExtraTitle.setText(text);
    }

    public void setTextExtraTitleColor(int color) {
        mTextExtraTitle.setTextColor(color);
    }

    public void setTextExtraTitleSize(float size) {
        mTextExtraTitle.setTextSize(size);
    }

    private void init(Context context) {
        mTextExtraTitle = new CuteTextView(context);
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        lp.addRule(RelativeLayout.RIGHT_OF, R.id.cute_toolbar_title);
        lp.addRule(RelativeLayout.CENTER_VERTICAL);
        float density = getResources().getDisplayMetrics().density;
        lp.leftMargin = (int) (4 * density);
        mTextExtraTitle.setLayoutParams(lp);
        getLayout().addView(mTextExtraTitle);
        setTextExtraTitleColor(CUTE_BLUE);
        float textSize = getResources().getDimension(R.dimen.text_size_large);
        float size = textSize / density;
        setTextExtraTitleSize(size);
    }
}
